public class Solution1 {
    public ListNode getIntersectionNode(ListNode headA, ListNode headB) {
        ListNode pl=headA;//永远指向最长的链表
        ListNode ps=headB;//永远指向最短的链表
        int lenA=0;
        while(pl!=null){
            lenA++;
            pl=pl.next;
        }
        int lenB=0;
        while(ps!=null){
            lenB++;
            ps=ps.next;
        }
        pl=headA;
        ps=headB;
        int len=lenA-lenB;
        if(len<0){
            pl=headB;
            ps=headA;
            len=lenB-lenA;
        }
        while(len!=0){
            pl=pl.next;
            len--;
        }
       while(pl !=ps){
           pl=pl.next;
           ps=ps.next;
       }
       if(pl==null){
           return null;
       }
        return pl;
    }
}